package com.itheima.mapper;

import com.itheima.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author：cxl
 * @Package：com.itheima.mapper
 * @Project：web-project
 * @name：DeptMapper
 * @Date：2025-09-25 9:43 am
 * @Filename：DeptMapper
 */
@Mapper
public interface DeptMapper {
    //@Results结果字段与实体类属性映射
    //Result每个结果字段与实体类属性映射
/*    @Results({
            @Result(property = "deptName", column = "dept_name"),
            @Result(property = "deptName", column = "dept_name")}
    )*/
    /* @Select("select id,name,create_time createTime,update_time updateTime from dept")*/
    @Select("select * from dept")
    List<Dept> findAll();

    @Delete("delete from dept where id=#{id}")
    int deleteById(Integer id);

    @Insert("insert into dept(name,create_time,update_time) values(#{name},#{createTime},#{updateTime})")
    int insert(Dept dept);

    @Update("update dept set name=#{name},update_time=#{updateTime} where id=#{id}")
    int update(Dept dept);

    @Select("select id,name,create_time,update_time from dept where id=#{id}")
    Dept selectById(Integer id);
}
